package whw.w2;

import jdk.swing.interop.SwingInterOpUtils;

public class Student {
    private String name;
    private int age = 30;//实例成员变量（非静态成员变量）
    public static String classroom;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("构造方法被执行了");
    }
    public Student(){
        System.out.println("不带参数的构造方法被执行了");
    }
    public int getAge() {
        return age;
    }

      public void setAge(int age) {
        this.age = age;
    }

    public String getname(){
        return this.name;
    }
    public void setName(String name){
        this.name = name;
    }
    static {
        System.out.println("静态代码块被执行了");
    }


    {   age = 9;
        System.out.println("实例代码块执行了");
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }  //静态方法（类方法）
    public static void testStatic(){
        System.out.println("静态方法被执行了");
        //testfunc();
        Student student = new Student("lisi",18);
        student.testfunc();
    }
    public void testfunc(){
        System.out.println("testfunc方法执行了");
        testStatic();
    }
}
